<form name="form" ng-init="vm.init();refresh(vm.callback);" ng-submit="vm.debug(form.$valid, vm.method)" novalidate>
  <script id="opt-toolbar" type="text/ng-template">
    <div>
      <button id="copy" class="btn btn-default" type="button" ng-disabled="vm.regexp == '' || !vm.regexp">
        <i class="fa fa-copy"></i> 复制</button>
      <button class="btn btn-default" type="button" ng-click="vm.reset()">
        <i class="fa fa-repeat"></i> 重置</button>
    </div>
  </script>
  <div class="row x-view-body">
    <div class="col-md-7 x-view-line">
      <div class="x-view-scope">
        <uib-tabset active="0" type="tabs">
          <uib-tab index="0" heading="元字符列表">
            <table class="table table-bordered">
              <thead>
                <tr>
                  <th width="10%">元字符</th>
                  <th width="90%">描述</th>
                </tr>
              </thead>
              <tbody>
                <tr ng-repeat="metachar in vm.metachars">
                  <td ng-bind-html="metachar.metachar"></td>
                  <td ng-bind-html="metachar.description"></td>
                </tr>
              </tbody>
            </table>
          </uib-tab>
          <uib-tab index="1" heading="常用正则表达式">
            <table class="table table-bordered">
              <thead>
                <tr>
                  <th width="50%">作用域</th>
                  <th width="50%">正则表达式</th>
                </tr>
              </thead>
              <tbody>
                <tr ng-repeat="regexp in vm.regexps">
                  <td ng-bind-html="regexp.scope"></td>
                  <td ng-bind-html="regexp.regexp"></td>
                </tr>
              </tbody>
            </table>
          </uib-tab>
        </uib-tabset>
      </div>
    </div>
    <div class="col-md-5">
      <div class="x-view-scope">
        <div class="form-group">
          <textarea rows="5" name="text" class="form-control" ng-model="vm.text" placeholder="匹配文本内容" autofocus
              required ng-class="{'x-invalid': form.$submitted && form.text.$invalid}"></textarea>
        </div>
        <div class="form-group">
          <div class="input-group">
            <input type="text" name="regexp" class="form-control" ng-model="vm.regexp" placeholder="正则表达式" required
                ng-class="{'x-invalid': form.$submitted && form.regexp.$invalid}">
            <span class="input-group-addon">
              <label class="checkbox-inline"><input type="checkbox" ng-model="vm.global">全局搜索</label>
              <label class="checkbox-inline"><input type="checkbox" ng-model="vm.caseIgnored">忽略大小写</label>
            </span>
            <span class="input-group-btn">
              <button type="submit" class="btn btn-default" ng-click="vm.method = 'match'"
                  ng-disabled="form.$invalid"><i class="fa fa-bug"></i> 测试匹配</button>
            </span>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label">匹配结果：</label>
          <textarea rows="8" class="form-control" ng-model="vm.match" readonly></textarea>
        </div>
        <div class="form-group">
          <div class="input-group">
            <input type="text" class="form-control" ng-model="vm.swap" placeholder="替换文本">
            <span class="input-group-btn">
              <button type="submit" class="btn btn-default" ng-click="vm.method = 'replace'"
                  ng-disabled="form.$invalid || vm.swap == ''"><i class="fa fa-exchange"></i> 替换</button>
            </span>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label">替换结果：</label>
          <textarea rows="5" class="form-control" ng-model="vm.replace" readonly></textarea>
        </div>
      </div>
    </div>
  </div>
</form>
